package it.scambiocorse.rowmapper;

import it.scambiocorse.model.FeedBackType;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.apache.log4j.Logger;
import org.springframework.dao.DataAccessException;
import org.springframework.jdbc.core.ResultSetExtractor;
import org.springframework.jdbc.core.RowMapper;

public class FeedbackRowMapper implements RowMapper {
	final Logger logger = Logger.getLogger(getClass());

	public Object mapRow(ResultSet rs, int row) throws SQLException {
		
		FeedBackType f = new FeedBackType();
		
		f.setIdFeed(rs.getInt("id_feed"));
		f.setIdUser(rs.getInt("id_user"));
		f.setIdUserInse(rs.getInt("id_user_inse"));
		f.setIdServ(rs.getInt("id_serv"));
		f.setFeedback(rs.getString("feedback"));
		f.setDataInse(rs.getTimestamp("data_inse"));
		f.setDataFine(rs.getTimestamp("data_fine"));
		f.setTipoFeedback(rs.getInt("tipo_feedback"));
		try {
			f.setIdUserInse(rs.getInt("utente_tab.id_user"));
			f.setNomeUserInse(rs.getString("utente_tab.login"));
		} catch (Exception e) {
			logger.debug("Catchata eccezione in FeedBackRowmapper");
		}
		return f;
	}

}
